<?php

class DefaultController extends AdminController
{
	/**
	 * This is the default 'index' action that is invoked
	 * when an action is not explicitly requested by users.
	 */
	public function actionIndex()
	{
		//$user = Yii::app()->user->getState('user');
		$user = User::model()->findByAttributes(array('username'=>Yii::app()->user->id));
		if($user->id ===null || $user->roles_id != 1){
            $this->renderPartial('loginform');
		}
		else if($user->roles_id == 1){
			$this->render('index');
		}
		
	}

	/**
	 * This is the action to handle external exceptions.
	 */
	public function actionError()
	{
		if($error=Yii::app()->errorHandler->error)
		{
			if(Yii::app()->request->isAjaxRequest)
				echo $error['message'];
			else
				$this->render('error', $error);
		}
	}
}